Skip to content

Add partition_key to Metadata so yield matches outlet_events - #71999

Closed
Vamsi-klu wants to merge 7 commits into
apache:mainfrom
Vamsi-klu:pr3/69117-metadata-partition-parity
Closed

Vamsi-klu wants to merge 7 commits into
apache:mainfrom
Vamsi-klu:pr3/69117-metadata-partition-parity

Conversation

@Vamsi-klu

@Vamsi-klu Vamsi-klu commented Aug 23, 2026 •

Copy link
Copy Markdown

What is the change?

Metadata gains an optional partition_keys field that takes one key or a list, the same values outlet_events[asset].add_partitions accepts. The sync and async callback runners call add_partitions when it is set, so yielding Metadata records partitions exactly like the accessor API.

Why did I do it?

closes: #69117

The docs said the two APIs were equivalent. For extra they are; for partitions they were not. Setting extra never selects a partition, so a partitioned consumer got no AssetPartitionDagRun and users had no yield-based way to attach a key.

How did I do it?

partition_keys: str | list[str] | None = None is the last field, so existing positional Metadata(asset, extra) calls keep working. After merging extra, the runner calls add_partitions. Invalid keys raise and fail the task before any event is emitted. Keys land on the concrete asset accessor only; alias-resolved events keep the producing Dag run's key. I updated the assets docs with the equivalence and the partitioned-consumer rules.

What's the impact?

Task authors can attach partition keys from a yield. Extra-only emits to a partitioned consumer still log a missing-key warning and create no run. No scheduler change.

What's the test plan?

New test_callback_runner.py covers merging, list keys, alias interaction, and invalid keys for both runners. Parity tests in test_scheduler_job.py run both APIs and compare events, AssetPartitionDagRun rows, and consumer runs. test_taskinstance.py adds mapped injection and invalid-key tests; test_task_runner.py pins serialization.


Was generative AI tooling used to co-author this PR?
  • Yes (Grok 4.6)

Generated-by: Grok 4.6 following the guidelines

@Vamsi-klu

This comment was marked as spam.

@uranusjr
uranusjr requested a review from Lee-W August 23, 2026 07:51
Vamsi-klu and others added 4 commits August 24, 2026 00:18
Docs treated yield Metadata and outlet_events as the same API. Extra
already merged onto the same accessor, but partitioned consumers need
an explicit key and extra was never a substitute.

closes: apache#69117
The upgrade note pointed at an unmerged batching PR, alias docs did not
say where partition_key is recorded, and one ADRQ assertion counted the
whole table.
The check rejects issue-numbered fragments so the changelog entry
links to the change that actually merged.

Co-authored-by: Cursor <cursoragent@cursor.com>
The check rejects a fragment named for an older number so the
changelog entry links to the change that actually merged.

Co-authored-by: Cursor <cursoragent@cursor.com>
@cursor
cursor Bot force-pushed the pr3/69117-metadata-partition-parity branch from eba6c0d to b192b4a Compare August 24, 2026 00:18
Comment thread airflow-core/newsfragments/71999.bugfix.rst Outdated
Comment thread task-sdk/src/airflow/sdk/definitions/asset/metadata.py Outdated
cursoragent and others added 3 commits August 24, 2026 16:02
The two emit APIs should take the same keys argument. A single-key field still forced one yield per partition, and the changelog called that a bug when it is just the missing side of the API.
@shahar1 shahar1 closed this Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inconsistency between yielding Metadata and outlet_events extras for partitioned Assets

4 participants